import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_switch/flutter_switch.dart';
import 'package:xinxuan/utils/color_util.dart';

class ToggleDefaultItem extends StatelessWidget {

  final String title;
  final bool value;
  final ValueChanged<bool> onToggle;
  final bool showBorder;
  ToggleDefaultItem({
    required this.title,
    required this.value,
    required this.onToggle,
    this.showBorder = true
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 12.w),
      color: bgWhiteColor,
      child: Container(
        height: 54.h,
        padding: EdgeInsets.symmetric(horizontal: 4.w),
        decoration: BoxDecoration(
          border: Border(
            bottom: showBorder ? BorderSide(
              width: .5,
              color: lineColor
            ) : BorderSide.none
          )
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Container(
              child: Text(
                title,
                style: TextStyle(
                  color: textBlackColor,
                  fontSize: 16.sp
                ),
              ),
            ),
            Container(
              alignment: Alignment.centerLeft,
              child: FlutterSwitch(
                value: value, 
                activeColor: bgMainColor,
                width: 54.w,
                height: 30.h,
                onToggle: (bool value) => onToggle(value)
              ),
            )
          ],
        ),
      )
    );
  }
}